package com.shujia.mllib

import org.wltea.analyzer.core.IKSegmenter
import org.wltea.analyzer.core.Lexeme

import java.io.StringReader
import scala.collection.mutable.ListBuffer

object Demo07IK {
  def main(args: Array[String]): Unit = {
    val text: String = "数加学院牛逼"

    println(fit(text))

  }

  def fit(text: String): List[String] = {

    val lb: ListBuffer[String] = ListBuffer[String]()

    val ik = new IKSegmenter(new StringReader(text), true)

    var lexeme: Lexeme = ik.next()
    while (lexeme != null) {
      val word: String = lexeme.getLexemeText
      lb.append(word)
      lexeme = ik.next()
    }
    lb.toList
  }

}
